/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package onlinestore.GUI;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;
import onlinestore.Product;

/**
 *
 * @author eid
 */
public class HomeFrame extends JFrame  implements ActionListener{
    JMenuBar mb = new JMenuBar();
    private JTextField searchTextField = new JTextField();
    JButton pSearch = new JButton("Search");
    SORFile st = new SORFile();
    Product p = new Product();

    public HomeFrame()
    {
        System.out.println("Open the home Page...");

        //menu bar
        JMenu user = new JMenu("User");
        JMenuItem login = new JMenuItem("Log in");
        mb.add(user);
        user.add(login);
        add(mb);

        //seacrch text feild
        searchTextField.setBackground(Color.WHITE);
        searchTextField.setBounds(200,200, 350, 30);
        searchTextField.setFont(new Font("Courier New",Font.PLAIN,16));
        
        add(searchTextField);

        //search button
        pSearch.setBounds(600, 200, 80, 30);
        add(pSearch);
        pSearch.addMouseListener(new MouseListener() {

            public void mouseClicked(MouseEvent e) {
            }

            public void mousePressed(MouseEvent e) {
                st.saveToFile(searchTextField.getText());
                SearchFrame s = new SearchFrame();
                p.finProduct(searchTextField.getText());
                s.setVisible(true);
                
            }

            public void mouseReleased(MouseEvent e) {
            }

            public void mouseEntered(MouseEvent e) {
            }

            public void mouseExited(MouseEvent e) {
            }
        });

        //classification
        JButton books = new JButton("BOOKS");
        books.setBounds(200, 400, 80, 30);
        add(books);
        books.addMouseListener(new MouseListener() {

            public void mouseClicked(MouseEvent e) {
            }

            public void mousePressed(MouseEvent e) {
                ProductFrame p = new ProductFrame();
                p.setVisible(true);
            }

            public void mouseReleased(MouseEvent e) {
            }

            public void mouseEntered(MouseEvent e) {
            }

            public void mouseExited(MouseEvent e) {
            }
        });

        //classification
        JButton toys = new JButton("TOYS");
        toys.setBounds(300, 400, 80, 30);
        add(toys);
        books.addMouseListener(new MouseListener() {

            public void mouseClicked(MouseEvent e) {
            }

            public void mousePressed(MouseEvent e) {
            }

            public void mouseReleased(MouseEvent e) {
            }

            public void mouseEntered(MouseEvent e) {
            }

            public void mouseExited(MouseEvent e) {
            }
        });

        //LOGO

        ImageIcon LOGOpic = new ImageIcon("pic_homePage/homePage_bg.PNG");
        JLabel LOGO = new JLabel(LOGOpic);
        LOGO.setBounds(200, 0, 200, 500);
        add(LOGO);
        
        Container contentPane = getContentPane();
        contentPane.setBackground(Color.WHITE);
        contentPane.setLayout(new BorderLayout());
        setTitle("Could --- Online Store");
        setBounds(0, 0, 800, 600);
        setLocationRelativeTo(null);
        setJMenuBar(mb);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
           
    }

     public void actionPerformed(ActionEvent e)
     {
        throw new UnsupportedOperationException("Not supported yet. "+e);
     }


}
